<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('新增部门')" />
</head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-dept-add">
			<input id="parentId" name="parentId" type="hidden" th:value="${dept.id}"   />
			<input id="groupId" name="groupId" type="hidden" th:value="${dept.id}"   />
			<div class="form-group">
				<label class="col-sm-3 control-label">上级部门：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" id="treeName" readonly="true" th:value="${dept.orgName}">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">部门名称：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="orgName" id="orgName" required>
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">负责人：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="leader">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">联系电话：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="phone">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">部门状态：</label>
				<div class="col-sm-8">
				    <select class="form-control" name="status" >
						<option value="1">开启</option>
						<option value="2">关闭</option>
					</select>
				</div>
			</div>
		</form>
	</div>
	<th:block th:include="include :: footer" />
	<script type="text/javascript">
		var prefix = ctx + "sys/org";
		
		$("#form-dept-add").validate({
			onkeyup: false,
			rules:{
				orgName:{
					required:true,
					minlength:2,
					maxlength:30
				},
        		phone:{
        			isPhone:true
        		},
			},
			messages: {
				orgName: {
					required:"请输入部门名称",
					minlength:"最少两个长度",
					maxlength:"最多30个长度"
		        }
		    },
		    focusCleanup: true
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
				$.operate.save(prefix + "/insert", $('#form-dept-add').serializeJson(),null,true);
	        }
	    }

	</script>
</body>
</html>
